﻿using AutoMapper;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using WMS.FC.Domain.DomainObject.System;
using WMS.FC.Domain.PersistenceObject.History;
using WMS.FC.Domain.Repository;
using WMS.FC.Domain.Service.System.Interface;

namespace WMS.FC.Domain.Service.System
{
    public class GetSplitTableDataService : ServiceBase, IGetSplitTableDataService
    {
        protected readonly ISplitTableRepository splitTableRepository;

        public GetSplitTableDataService(
            ILogger<ServiceBase> logger,
            IOptions<WmsSettings> options,
            IMapper mapper,
            ISplitTableRepository splitTableRepository)
            : base(logger, options, mapper)
        {
            this.splitTableRepository = splitTableRepository;
        }

        public async Task<ActionResult<PageDataDO>> GetSplitTableData(string menuId, Dictionary<string, object>? parameters, Pagination? pagination, Sorter? sorter, UserInfo userInfo)
        {
            var result = new ActionResult<PageDataDO>("获取页面分表数据");
            try
            {
                var table = await splitTableRepository.ExecuteQuery<HisCellBindPO>(new DateTime(2022, 11, 1), new DateTime(2022, 12, 31), new Dictionary<string, object>()
                {
                    { "cell_position",1}
                });

            }
            catch (Exception ex)
            {
                return result.Exception(ex);
            }

            return result;
        }
    }
}
